/**
 * Copyright 2011 By Shayne, Zhang.
 * 
 * The contents of this file are developped by Shayne, Zhang. You may visit:
 * http://www.shaynez.com for more details.
 *
 */
package com.shaynez.ec.element;

import com.shaynez.ec.Constants;
import com.shaynez.ec.exception.InvalidateValueException;

/**
 * @author shayne zhang
 *
 */
public class Sensitivity implements Calculatable<Sensitivity>, ExposureElement{

	private double value;
	
	protected Sensitivity(double value){
		this.value = value;
	}
	
	public static Sensitivity getInstance(double value) throws InvalidateValueException{
		if(value < Constants.THE_MIN_SENSITIVITY_VALUE || value > Constants.THE_MAX_SENSITIVITY_VALUE){
			throw new InvalidateValueException("Invalidate Sensitivity value > " + value);
		}
		return new Sensitivity(value);
	}
	
	@Override
	public double getValue(){
		return value;
	}
	
	@Override
	public double getExposureValue() {
		// TODO Auto-generated method stub
		return value;
	}

	@Override
	public double getValueByExposureValue(double exposureValue) {
		// TODO Auto-generated method stub
		return exposureValue;
	}

	@Override
	public Factor compare(Sensitivity o) {
		// TODO Auto-generated method stub
		return new Factor(this.getExposureValue() / o.getExposureValue());
	}

	@Override
	public Sensitivity calculate(Factor factor) throws InvalidateValueException {
		// TODO Auto-generated method stub
		return Sensitivity.getInstance(this.getValueByExposureValue(this.getExposureValue() / factor.getValue()));
	}
	
	
}
